﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true"
    CodeBehind="Edit.aspx.cs" Inherits="Yonkly.Views.Profile.Edit" %>

<%@ Import Namespace="Yonkly.Controllers" %>
<%@ Import Namespace="Yonkly.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script type="text/javascript" src='<%=Page.ResolveClientUrl("~/content/scripts/Profile.js")%>'></script>

    <script type="text/javascript" src='<%=Page.ResolveClientUrl("~/content/scripts/twitterimport.js")%>'></script>

    <script type="text/javascript">
 $(document).ready(function(){
            Profile.init();
        });
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    <div class="profile">
        <h2>
            Settings</h2>
        <div class="form">
            <h2>
                General Information</h2>
            <p>
                <label for="txtEmail" class="label">
                    Email:</label>
                <input id="txtEmail" type="text" class="textbox" value='<%=ViewData.Model.LoggedInUser.Email%>' />
                <div id="valEmail" class="validator" style="display: none">
                </div>
            </p>
            <p>
                <label for="txtName" class="label">
                    Name:</label>
                <input id="txtName" type="text" class="textbox" value='<%=((ProfileViewData)ViewData.Model).Name%>' />
                <div id="valName" class="validator" style="display: none">
                </div>
            </p>
            <p>
                <label for="txtUrl" class="label">
                    Blog/Website:</label>
                <input id="txtUrl" type="text" class="textbox" value='<%=((ProfileViewData)ViewData.Model).Url%>' />
                <div id="valUrl" class="validator" style="display: none">
                </div>
            </p>
            <p>
                <label for="txtAbout" class="label">
                    About:</label>
                <textarea id="txtAbout" class="textbox"><%=((ProfileViewData)ViewData.Model).About%></textarea>
                <div id="valAbout" class="validator" style="display: none">
                </div>
            </p>
            <p>
                <label class="label">
                    Email me when:
                </label>
                <p>
                    <label class="label">
                    </label>
                    <label>
                        <input id="chkEmailOnFollow" type="checkbox" checked='<%= ((ProfileViewData)ViewData.Model).ReceiveEmailOnFollow ? "checked" : ""%>' />someone
                        follows me</label>
                </p>
                <p>
                    <label class="label">
                    </label>
                    <label>
                        <input id="chkEmailOnReply" type="checkbox" checked='<%= ((ProfileViewData)ViewData.Model).ReceiveEmailOnResponse ? "checked" : ""%>' />someone
                        replies to my messages</label>
                </p>
            </p>
            <div id="infoMessage" class="message" style="display: none">
            </div>
            <p>
                <label class="label">
                </label>
                <input id="btnSave" type="button" class="button" value="save changes" onclick="javascript:Profile.updateProfile();" />
            </p>
        </div>
        <div class="divider">
        </div>
        <div class="form">
            <h2>
                Twitter Integration</h2>
            <p>
                If you would like integrate with Twitter, please enter your Twitter username and
                password below.
            </p>
            <p>
                If you would like to cancel your Twitter integration then clear the information
                below and click the save button.</p>
            <br />
            <p>
                <label for="txtTwitterName" class="label">
                    Twitter Username:</label>
                <input id="txtTwitterName" type="text" class="textbox" value='<%=((ProfileViewData)ViewData.Model).TwitterUserName %>' />
                <div id="valTwitterName" class="validator" style="display: none">
                </div>
            </p>
            <p>
                <label for="txtTwitterPassword" class="label">
                    Twitter Password:</label>
                <input id="txtTwitterPassword" type="password" class="textbox" />
                <div id="valTwitterPassword" class="validator" style="display: none">
                </div>
            </p>
            <div id="twitterMessage" class="message" style="display: none">
            </div>
            <p>
                <label class="label">
                </label>
                <input id="btnTwitterSave" type="button" class="button" value="save twitter info"
                    onclick="javascript:Profile.updateTwitter();" />
            </p>
            <br />
            <p>
                You can also import your twitter messages into yonkly by click below</p>
            <p>
                <label class="label">
                </label>
                <%--<%=Html.ActionLink<TwitterController>(t=> t.Import(),"import twitter messages") %>--%>
                <a href="#" onclick='javascript:$("#dviTwitterImport").modal({overlay:50});'>import
                    twitter messages</a>
            </p>
        </div>
        <div class="divider">
        </div>
        <div class="form">
            <h2>
                Change Password</h2>
            <p>
                <label for="txtOldPassword" class="label">
                    Old Password:</label>
                <input id="txtOldPassword" type="password" class="textbox" />
                <div id="valOldPassword" class="validator" style="display: none">
                </div>
            </p>
            <p>
                <label for="txtNewPassword" class="label">
                    New Password:</label>
                <input id="txtNewPassword" type="password" class="textbox" />
                <div id="valNewPassword" class="validator" style="display: none">
                </div>
            </p>
            <div id="changePasswordMessage" class="message" style="display: none">
            </div>
            <p>
                <label class="label">
                </label>
                <input id="btnChangePassword" type="button" class="button" value="change password"
                    onclick="javascript:Profile.changePassword();" />
            </p>
        </div>
        <div class="divider">
        </div>
        <div class="form">
            <h2>
                Profile Picture</h2>
            <table>
                <tr>
                    <td>
                        <% Html.RenderPartial("~/views/shared/gravatarcontrol.ascx",
                                                     new GravatarData
                                                         {
                                                             UserName = ViewData.Model.LoggedInUser.UserName,
                                                             Email = ViewData.Model.LoggedInUser.Email,
                                                             Size = 64
                                                         });%>
                    </td>
                    <td>
                        <p>
                            We are using Gravatar for the profile picture. You can change it at <a href='http://www.gravatar.com'
                                target="_blank">http://www.gravatar.com</a>.</p>
                        <p>
                            <b>Note: </b>Your email address above must match your email at Gravatar for your
                            profile picture to come through.</p>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div id="dviTwitterImport" class="modalBox" style="width: 440px; display: none">
        <div class="titleContainer">
            <div class="title">
                Yonkly</div>
            <div id="divMembershipClose" class="closeButton" title="Close" onclick="javascript:$.modal.close();">
            </div>
        </div>
        <div class="contentContainer">
            <div>
                <%if (ViewData.Model.IsAuthenticated)
                  {%>
                <%if (string.IsNullOrEmpty(ViewData.Model.LoggedInUser.TwitterUserName) || string.IsNullOrEmpty(ViewData.Model.LoggedInUser.TwitterPassword))
                  {%>
                You need to setup your twitter username and passwords before you can import your
                tweets. To setup your twitter information
                <%=Html.ActionLink<ProfileController>(p => p.Edit(), "click here")%>
                <%}//password or username are null
                  else
                  { %>
                <p>
                    To begin the import process, please click the button below. Wait for the import
                    to finish before navigating away from the page.</p>
                <p>
                    Due to limits imposed by twitter, we can only import 200 messages per page and only
                    7 pages, so only your newest 1400 messages will be imported.</p>
                <p>
                    Note: If you run the process again, it will not import messages that have already
                    been imported.</p>
                <input type="button" name="btnImport" id="btnImport" value="begin import" onclick="javascript:TwitterImport.beginImport();" /><img
                    id="imgImportProgress" name="imImportProgress" src='/content/images/progress.gif'
                    style="display: none" />
                <br />
                <div id="importStatus">
                </div>
                <%}//twitter password and usernames are available %>
                <%}// is authenticated
                  else
                  { %>
                You must be logged in to import your twitter messages. Please login first.
                <%} %>
            </div>
        </div>
    </div>
</asp:Content>
